var Adv_skd=require("./Adv_skd")
var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0}), e("ADConfigs");
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("GameModuleViewMediator"),
    d = e("GameData"),
    u = e("ProgressTaskData"),
    p = cc._decorator,
    h = p.ccclass,
    f = p.property,
    _ =
        (window.wx,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (
                    (t.btn_shareRecorder = null),
                    (t.snakeName = ""),
                    (t.content = null),
                    (t.target_parent_act = null),
                    (t.sprite_timer = null),
                    (t.progressTask = null),
                    (t.isLookAd = !1),
                    (t.dt = 10),
                    (t.timer_idnex = 0),
                    t
                );
            }
            return (
                a(t, e),
                (t.prototype.onResetView = function () {
                    cc.SDK.showBanner(), e.prototype.onResetView.call(this), this.init();

                    Adv_skd.default.instance.hideAllAdv();

                    Adv_skd.default.instance.showGridAdLeft();
                    Adv_skd.default.instance.showGridAdRight();
                }),
                (t.prototype.registerMediator = function () {
                    e.prototype.registerMediator.call(this);
                }),
                (t.prototype.removeMediator = function () {
                    e.prototype.removeMediator.call(this);
                }),
                (t.prototype.onDisable = function () {
                    cc.SDK.hideBanner(),
                        ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.hideBanner(!1),
                        ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.hideBanner(!1);
                }),
                (t.prototype.addEvent = function () {
                    e.prototype.addEvent.call(this),
                        this.content
                            .getChildByName("btn_lookAd")
                            .on(game.EngineEventType.NodeEvent.click, this.btn_lookAd, this),
                        this.content
                            .getChildByName("btn_lookAdbNo")
                            .on(game.EngineEventType.NodeEvent.click, this.btn_lookAdbNo, this),
                        this.btn_shareRecorder.on(
                            game.EngineEventType.NodeEvent.click,
                            this.btnClick_shareRecorder,
                            this
                        );
                }),
                (t.prototype.removeEvent = function () {
                    e.prototype.removeEvent.call(this),
                        this.content
                            .getChildByName("btn_lookAd")
                            .off(game.EngineEventType.NodeEvent.click, this.btn_lookAd, this),
                        this.content
                            .getChildByName("btn_lookAdbNo")
                            .off(game.EngineEventType.NodeEvent.click, this.btn_lookAdbNo, this),
                        this.btn_shareRecorder.off(
                            game.EngineEventType.NodeEvent.click,
                            this.btnClick_shareRecorder,
                            this
                        );
                }),
                (t.prototype.init = function () {
                    (this.isCache = !1),
                        (this.snakeName = this.param.snakeName),
                        (this.content = this.node.getChildByName("content")),
                        (this.target_parent_act = this.content.getChildByName("target_parent_act")),
                        (this.sprite_timer = this.content.getChildByName("sprite_timer")),
                        this.playAni(),
                        (this.progressTask = this.content.getChildByName("progressTask"));
                    for (
                        var e = d.default.instance.SelfPlayerData.fraction,
                            t = u.default.instance.getScore(),
                            o = u.default.instance.taskListScore,
                            n = 0,
                            i = e + t,
                            a = 0;
                        a < o.length;
                        a++
                    )
                        i >= (r = o[a]) && (n = a + 1);
                    if (n == o.length) this.progressTask.active = !1;
                    else {
                        var r = o[n] - i,
                            s = u.default.instance.taskListName[n];
                        this.progressTask.getChildByName("label_RichText").getComponent(cc.RichText).string =
                            "<color=#3D4088>再赢</color><color=#A84400>" +
                            r +
                            "</c><color=#3D4088>长度即可</color><br/><color=#3D4088>获得</color><color=#A84400>" +
                            s +
                            "</c>";
                    }
                }),
                (t.prototype.btnClick_shareRecorder = function () {}),
                (t.prototype.playAni = function () {
                    this.target_parent_act.children.forEach(function (e, t) {
                        e.scale = 0;
                        var o = cc.scaleTo(0.5, 1),
                            n = cc.scaleTo(0.5, 0),
                            i = 0.1 * t,
                            a = 1 - i,
                            r = cc.sequence(cc.delayTime(i), o, n, cc.delayTime(a)),
                            s = cc.repeatForever(r);
                        e.runAction(s);
                    });
                }),
                (t.prototype.stopAni = function () {
                    this.target_parent_act.children.forEach(function (e) {
                        e.stopAllActions();
                    });
                }),
                (t.prototype.update = function (e) {
                    if (!this.isLookAd)
                        if (this.dt < 0) this.btn_lookAdbNo();
                        else {
                            this.dt -= e;
                            var t = Math.ceil(this.dt / 2);
                            if (t != this.timer_idnex && t > 0) {
                                this.timer_idnex = t;
                                var o = "CountDownView_timer_" + this.timer_idnex,
                                    n = game.BundleManager.instance
                                        .getBundle(c.default.Popup)
                                        .get(
                                            s.default.PopupMap.CountDownView.preAssets.textures.assetsList[o],
                                            cc.SpriteFrame
                                        );
                                this.sprite_timer.getComponent(cc.Sprite).spriteFrame = n;
                            }
                        }
                }),
                (t.prototype.btn_lookAd = function () {
                    game.AudioManager.playBtnEffect();
                    var e = ad.curr_platform === window.ad.Platform.TOU_TIAO;
                    d.default.instance.GameModel === d.GameModel.endless &&
                        (game.log("T=> 无尽模式复活"), e && window.tt.reportAnalytics("FuHuo", {}));
                    var t = this;
                    ad.adInterface.showRewardedVideo(
                        function () {
                            (t.isLookAd = !0), (d.default.instance.gameState = d.GameState.stop);
                        },
                        function () {
                            t.isLookAd = !1;
                        },
                        function () {
                            d.default.instance.againPlayTimes++,
                                t.closeView(!1),
                                (d.default.instance.gameState = d.GameState.play),
                                game.appFacade.sendNotification(l.default.PlayAgain, {snakeName: t.snakeName});
                        }
                    );
                }),
                (t.prototype.btn_lookAdbNo = function () {
                    game.AudioManager.playBtnEffect(),
                        this.closeView(!1),
                        game.PopupManager.instance.showPopView(s.default.PopupMap.ProgressTaskView, null, !1, !1);
                }),
                r([f(cc.Node)], t.prototype, "btn_shareRecorder", void 0),
                r([h], t)
            );
        })(game.BasePopView));
i.default = _;
